<%--
  Created by IntelliJ IDEA.
  User: oldliu
  Date: 2023-06-05
  Time: 16:20
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
    request.setCharacterEncoding("utf-8");
    String n=request.getParameter("name");
    String p=request.getParameter("pass");
    if(n.startsWith("java83") &&p.equals("12345")){
        //out.print("you are welcome!");
        //显示students.jsp
       // request.getRequestDispatcher("students.jsp").forward(request,response);
        //response.sendRedirect("students.jsp");
        session.setAttribute("USER_LOGIN",n);
        //同时存入cookie
        Cookie c=new Cookie("UNAME",n);
        c.setMaxAge(86400*7);
        response.addCookie(c);
        response.sendRedirect("main.jsp");
        return;
    }else{
        ///>out.print("错误的用户名或者密码！");
        request.setAttribute("tip","错误的用户名或者密码！");
        request.getRequestDispatcher("/login.jsp").forward(request,response);
    }
%>

</body>
</html>
